﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
	x:Class="nRoute.Samples.Netflix.Views.TitleView"
    xmlns:n="http://nRoute/schemas/2010/xaml" 
	mc:Ignorable="d" FontFamily="Arial" FontSize="16" 
    d:DesignHeight="600" d:DesignWidth="900">
	
	<UserControl.Resources>
		<n:ValueConverterRelay x:Name="SecondsToTimeConverter" />
		<n:ValueConverterRelay x:Name="StripHTMLConverter" />
		<n:ValueConverterRelay x:Name="BoxArtUrlConverter" />
		<n:ValueConverterRelay x:Name="RatingToWidthConverter" />
	</UserControl.Resources>
    
	<i:Interaction.Behaviors>
		<n:BridgeViewModelBehavior/>
	</i:Interaction.Behaviors>
    
	<ScrollViewer x:Name="LayoutRoot" Background="WhiteSmoke" BorderThickness="0" 
		BorderBrush="{x:Null}" DataContext="{Binding MovieTitle}" VerticalScrollBarVisibility="Auto">
		<Grid >
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="236"/>
				<ColumnDefinition/>
			</Grid.ColumnDefinitions>
			<Border HorizontalAlignment="Left" Height="300" Margin="8" MinWidth="220" MinHeight="300" 
				VerticalAlignment="Top" Width="220" BorderThickness="1" BorderBrush="#FFE2E2E2">
				<Border.Background>
					<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
						<GradientStop Color="#FFFDF9F9" Offset="1"/>
						<GradientStop Color="#FEFFFFFF"/>
					</LinearGradientBrush>
				</Border.Background>
				<Image Source="{Binding BoxArt, Converter={StaticResource BoxArtUrlConverter}, FallbackValue='/Resources/PlaceHolder.png'}" 
					Stretch="UniformToFill" Cursor="Hand">
					<i:Interaction.Triggers>
						<i:EventTrigger EventName="MouseLeftButtonUp">
							<n:NavigateAction Url="Content/Netflix/BoxArt/" HandlerName="PopupContainer">
								<n:DependencyParameter Key="BoxArt" Value="{Binding BoxArt}"/>
							</n:NavigateAction>
						</i:EventTrigger>
					</i:Interaction.Triggers>
				</Image>
			</Border>
			<StackPanel Grid.Column="1" Margin="8" Orientation="Vertical" VerticalAlignment="Top">
				<TextBlock FontFamily="Arial" FontSize="32" TextWrapping="Wrap"><Run Text="{Binding Name}" /><Run Text=" "/><Run Text="{Binding ReleaseYear, StringFormat=(\{0\})}" /></TextBlock>
				<TextBlock TextWrapping="Wrap" Foreground="#FF8F8F8F" Margin="0,4,0,0" HorizontalAlignment="Left" Cursor="Hand">
					<i:Interaction.Triggers>
						<i:EventTrigger EventName="MouseLeftButtonUp">
							<n:NavigateAction Url="Content/Rating/" HandlerName="PopupContainer"/>
						</i:EventTrigger>
					</i:Interaction.Triggers><Run Text="{Binding Rating, StringFormat=Rated \{0\} |, FallbackValue='No Rating Info |'}" />
					<Run Text=" "/><Run Text="{Binding Runtime, Converter={StaticResource SecondsToTimeConverter}, StringFormat=\{0\} |, FallbackValue='Unknown Runtime |'}" />
					<Run Text=" "/><Run Text="{Binding Type}" /></TextBlock>
				<TextBlock HorizontalAlignment="Left"><Run Text="{Binding Series}" /><Run Text=" "/><Run Text="{Binding Season, StringFormat=(Season \{0\})}" /></TextBlock>
				
				<TextBlock Margin="0,20,0,5" Foreground="#FF85878B" HorizontalAlignment="Left"
					FontSize="16" FontFamily="Trebuchet MS" TextOptions.TextHintingMode="Animated" FontWeight="Bold">
					<Run Text="Average Rating"/>
					<Run Text="{Binding AverageRating, FallbackValue=--}" FontWeight="Bold"/>
					<Run Text="/ 5" />
				</TextBlock>
				<Canvas Height="20" Width="100" HorizontalAlignment="Left">
					<Image Width="100" Height="20" Source="/nRoute.Samples.Netflix;component/Resources/EmptyStars.png" Stretch="None"/>
					<Image Width="{Binding AverageRating, Converter={StaticResource RatingToWidthConverter}}" 
						Height="20" Source="/nRoute.Samples.Netflix;component/Resources/FullStars.png" Stretch="None"/>						
				</Canvas>	
				
				<TextBlock Text="Synopsis" Margin="0,20,0,5" Foreground="#FF85878B" HorizontalAlignment="Left"
					FontSize="16" FontFamily="Trebuchet MS" TextOptions.TextHintingMode="Animated" FontWeight="Bold">
					<TextBlock.Effect>
						<DropShadowEffect ShadowDepth="1" BlurRadius="2" Color="White" Direction="-247"/>
					</TextBlock.Effect>
				</TextBlock>
				<TextBlock Text="{Binding Synopsis, Converter={StaticResource StripHTMLConverter}}" 
					TextWrapping="Wrap" LineHeight="26"/>
						
				<TextBlock Text="Director(s)" Margin="0,20,0,5" Foreground="#FF85878B" HorizontalAlignment="Left"
					FontSize="16" FontFamily="Trebuchet MS" TextOptions.TextHintingMode="Animated" FontWeight="Bold">
					<TextBlock.Effect>
						<DropShadowEffect ShadowDepth="1" BlurRadius="2" Color="White" Direction="-247"/>
					</TextBlock.Effect>
				</TextBlock>
				<ItemsControl ItemsSource="{Binding Directors}" ItemTemplate="{StaticResource PersonLinkTemplate}"/>
						
				<TextBlock Text="Cast" Margin="0,20,0,5" Foreground="#FF85878B" HorizontalAlignment="Left"
					FontSize="16" FontFamily="Trebuchet MS" TextOptions.TextHintingMode="Animated" FontWeight="Bold">
					<TextBlock.Effect>
						<DropShadowEffect ShadowDepth="1" BlurRadius="2" Color="White" Direction="-247"/>
					</TextBlock.Effect>
				</TextBlock>
				<ItemsControl ItemsSource="{Binding Cast}" ItemTemplate="{StaticResource PersonLinkTemplate}"/>
			</StackPanel>
			<StackPanel Margin="8,320,8,0" VerticalAlignment="Top">
				<TextBlock Text="Genre(s)" Margin="0,0,0,5" Foreground="#FF85878B" HorizontalAlignment="Right"
					FontSize="16" FontFamily="Trebuchet MS" TextOptions.TextHintingMode="Animated" FontWeight="Bold">
					<TextBlock.Effect>
						<DropShadowEffect ShadowDepth="1" BlurRadius="2" Color="White" Direction="-247"/>
					</TextBlock.Effect>
				</TextBlock>
				<ItemsControl ItemsSource="{Binding Genres}" ItemTemplate="{StaticResource GenreItemTemplate}"/>
				
				<TextBlock Text="Language(s)" Margin="0,10,0,5" Foreground="#FF85878B" HorizontalAlignment="Right"
					FontSize="16" FontFamily="Trebuchet MS" TextOptions.TextHintingMode="Animated" FontWeight="Bold">
					<TextBlock.Effect>
						<DropShadowEffect ShadowDepth="1" BlurRadius="2" Color="White" Direction="-247"/>
					</TextBlock.Effect>
				</TextBlock>
				<ItemsControl ItemsSource="{Binding Languages}" ItemTemplate="{StaticResource LanguageItemTemplate}"/>
				
			</StackPanel>
			
		</Grid>
	</ScrollViewer>

</UserControl>
